public methods for hal_mdb1.c More...
#include "msp430x24x.h"#include <stdio.h>#include "../Common/utilities.h"Defines | |
| #define | STATUS_LED_RED BIT6 |
| #define | STATUS_LED_GREEN BIT7 |
| #define | STATUS_LED_YELLOW (BIT6+BIT7) |
| #define | ALL_LEDS_OFF 0x3F |
| #define | HAL_SLEEP() ( __bis_SR_register(LPM3_bits + GIE)) |
| #define | HAL_WAKEUP() ( __bic_SR_register_on_exit(LPM3_bits)) |
| #define | HAL_ENABLE_INTERRUPTS() (_EINT()) |
| #define | HAL_DISABLE_INTERRUPTS() (_DINT()) |
| #define | HAL_CLEAR_INTERRUPTS() ( P2IFG = 0, P1IFG = 0, IFG2 &= ~UCA0RXIFG, UC1IFG &= ~UCA1RXIFG ) |
| #define | SRDY_INTERRUPT_FALLING_EDGE 0x01 |
| #define | SRDY_INTERRUPT_RISING_EDGE 0x00 |
| #define | RADIO_ON() (P1OUT |= BIT2) |
| #define | RADIO_OFF() (P1OUT &= ~BIT2) |
| #define | SPI_SS_SET() (P5OUT &= ~BIT0) |
| #define | SPI_SS_CLEAR() (P5OUT |= BIT0) |
| #define | SRDY_IS_HIGH() (P1IN & BIT3) |
| #define | SRDY_IS_LOW() ((~P1IN) & BIT3) |
| #define | DEBUG_ON() (P6OUT |= BIT6) |
| #define | DEBUG_OFF() (P6OUT &= BIT6) |
| #define | DEBUG_TOGGLE() (P6OUT ^= BIT6) |
| #define | GET_MCLK_FREQ() 8000000L |
| #define | XTAL 8000000L |
| #define | TICKS_IN_ONE_MS_8MHZ 1980 |
| #define | TICKS_IN_ONE_MS TICKS_IN_ONE_MS_8MHZ |
| #define | TICKS_IN_100_US 155 |
| #define | NO_WAKEUP 0 |
| #define | WAKEUP_AFTER_TIMER 1 |
| #define | WAKEUP_AFTER_SRDY 4 |
| #define | MASTER_BUTTON_0 0x00 |
| #define | MASTER_BUTTON_1 0x01 |
| #define | MASTER_BUTTON_2 0x02 |
| #define | MASTER_BUTTON_3 0x03 |
| #define | MASTER_BUTTON_4 0x04 |
| #define | BUTTON_LEDS_OFF 0xFF |
| #define | BAUD_RATE_9600 0x00 |
| #define | BAUD_RATE_19200 0x01 |
| #define | BAUD_RATE_38400 0x02 |
| #define | BAUD_RATE_115200 0x03 |
| #define | MCLK_1_DCO 0x00 |
| #define | MCLK_8_DCO 0x01 |
| #define | MCLK_8_XTAL 0x02 |
| #define | ACLK_VLO 0x00 |
| #define | ACLK_32_XTAL 0x01 |
| #define | ACLK_32_EXT 0x02 |
| #define | VLO_NOMINAL 12000 |
| #define | VLO_MIN (VLO_NOMINAL - (VLO_NOMINAL >> 2)) |
| #define | VLO_MAX (VLO_NOMINAL + (VLO_NOMINAL >> 2)) |
| #define | BIT_BANG_TX0_PORT P6OUT |
| #define | BIT_BANG_TX0_BIT BIT1 |
| #define | BIT_BANG_RX0_PORT P1IN |
| #define | BIT_BANG_RX0_BIT BIT4 |
| #define | DISABLE_BIT_BANG_RX0_INTERRUPT() (P1IE &= ~BIT4) |
| #define | ENABLE_BIT_BANG_RX0_INTERRUPT() (P1IE |= BIT4) |
| #define | BIT_BANG_TX1_PORT P6OUT |
| #define | BIT_BANG_TX1_BIT BIT2 |
| #define | BIT_BANG_RX1_PORT P1IN |
| #define | BIT_BANG_RX1_BIT BIT5 |
| #define | DISABLE_BIT_BANG_RX1_INTERRUPT() (P1IE &= ~BIT5) |
| #define | ENABLE_BIT_BANG_RX1_INTERRUPT() (P1IE |= BIT5) |
| #define | TOGGLE_DEBUG_PIN() (P4OUT ^= BIT5) |
Functions | |
| void | halInit () |
| void | delayMs (unsigned int ms) |
| void | toggleLed (unsigned char whichLed) |
| signed int | setLed (unsigned char led) |
| void | clearLeds () |
| void | halSpiInitZnp () |
| void | spiWrite (unsigned char *bytes, unsigned char numBytes) |
| void | setZnpInterfaceToInputs (void) |
| signed int | calibrateVlo () |
| signed int | initTimer (unsigned char seconds, unsigned char wakeOnTimer) |
| signed int | oscInit (unsigned char mainOscConfiguration, unsigned char auxOscConfiguration) |
| unsigned char | getSwitches () |
| unsigned char | getButtons () |
| void | testLEDs () |
| void | setStatusLed (unsigned char color) |
| void | setButtonLeds (unsigned char buttonId) |
| void | clearButtonLeds () |
| int | putcharAux (int c) |
| signed int | debugConsoleInit (unsigned char baudRate) |
| signed int | auxSerialPortInit (unsigned char baudRate) |
| void | stopTimerA () |
| void | delayUs (unsigned char hundredsOfMicroSeconds) |
| unsigned int | getVcc3 () |
public methods for hal_mdb1.c
YOU ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
| signed int auxSerialPortInit | ( | unsigned char | baudRate | ) |
Configures the Auxilliary Serial Port UART (USCIA1) with the specified baud rate. Also enables the Rx interrupt for this UART.
| signed int calibrateVlo | ( | ) |
Calibrate VLO. Once this is done, the VLO can be used semi-accurately for timers etc. Once calibrated, VLO is within ~2% of actual when using a 1% calibrated DCO frequency and temperature and supply voltage remain unchanged.
Calibrate VLO. Once this is done, the VLO can be used semi-accurately for timers etc. Once calibrated, VLO is within ~2% of actual when using a 1% calibrated DCO frequency and temperature and supply voltage remain unchanged. At room temperature, typical VLO frequencies seen are 9kHz (MSP430F248) and 12kHz (MSP430F2274)
| void clearButtonLeds | ( | ) |
Turns off the button LEDs and leaves status LED unchanged.
| void clearLeds | ( | ) |
Turns OFF LEDs.
Turn off all LEDs
Turns OFF the specified LED. Required for ZNP examples.
| led | the LED to turn off, must be 0,1,2,3,4. |
| signed int debugConsoleInit | ( | unsigned char | baudRate | ) |
Configures the debug console UART (USCIA0) for the specified baud rate, with oversampling Also enables the Rx interrupt for this UART.
| void delayMs | ( | unsigned int | ms | ) |
Blocking Delay in Milliseconds delays by at least the specified number of milliseconds (ms)
| ms | number of milliseconds to delay |
| unsigned char getButtons | ( | ) |
Reads the current status of the buttons
| unsigned char getSwitches | ( | ) |
Read value of the two Dual In-Line Package (DIP) switches.
| unsigned int getVcc3 | ( | ) |
Reads the MSP430 supply voltage using the Analog to Digital Converter (ADC). On CC2530ZNP target board, this is approx. 3600mV
Measures Vcc to the MSP430, nominally 3300mV
| void halInit | ( | ) |
Configures hardware for the particular hardware platform:
Configures hardware for the ZNP peripherals
Configures hardware for the particular board
| void halSpiInitZnp | ( | ) |
Initializes the Serial Peripheral Interface (SPI) interface to the Zigbee Network Processor (ZNP).
Configures the SPI port for ZNP operation
Initializes the SPI interface to the ZNP.
| signed int initTimer | ( | unsigned char | seconds, | |
| unsigned char | wakeOnTimer | |||
| ) |
Configures timer.
| seconds | period of the timer. Maximum is 0xFFFF / vloFrequency; or about 4 since VLO varies between 9kHz - 15kHz. Use a prescaler on timer (e.g. set IDx bits in TACTL register) for longer times. Maximum prescaling of Timer A is divide by 8. Even longer times can be obtained by prescaling ACLK if this doesn't affect other system peripherals. | |
| wakeOnTimer | whether to wake the processor after the timer interrupt. Must be either NO_WAKEUP or WAKEUP_AFTER_TIMER. |
Configures timer for source = ACLK
| seconds | period of the timer. Maximum is 0xFFFF / aClk; about 2 if using 32kHz xtal or about 4 if using VLO since VLO varies between 9kHz - 15kHz. Use a prescaler on timer (e.g. set IDx bits in TACTL register) for longer times. Maximum prescaling of Timer A is divide by 8. Even longer times can be obtained by prescaling ACLK if this doesn't affect other system peripherals. |
| signed int oscInit | ( | unsigned char | mainOscConfiguration, | |
| unsigned char | auxOscConfiguration | |||
| ) |
Stops the Watchdog timer and starts Oscillator based on the selected option. Halts if calibration constants erased.
| mainOscConfiguration | the main oscillator (MCLK) configuration - must be MCLK_1_DCO or MCLK_8_DCO or MCLK_8_XTAL | |
| auxOscConfiguration | the aux oscillator (ACLK) configuration - must be ACLK_VLO or ACLK_32_XTAL or ACLK_32_EXT |
| int putcharAux | ( | int | c | ) |
Send one byte via hardware UART to the auxilliary serial port. Aux Serial Port is USCIA1
| void setButtonLeds | ( | unsigned char | led | ) |
Turns on the specified button LED. Leaves status LED unchanged.
| whichLed | the LED to turn on, must be 0-4. |
| signed int setLed | ( | unsigned char | led | ) |
Turns ON the specified LED.
| led | the LED to turn on, must be 0 or 1. |
Turn on the specified LED
Turns ON the specified LED. Required for ZNP examples.
| led | the LED to turn on, must be 0,1,2,3,4. |
| void setStatusLed | ( | unsigned char | color | ) |
Sets the status LED to a particular color. Leaves the other LEDs unchanged. The status LED is a two-element LED (red+green) that is capable of displaying red, green, or yellow.
| color | the color to set, must be STATUS_LED_RED, STATUS_LED_GREEN, or STATUS_LED_YELLOW. |
| void setZnpInterfaceToInputs | ( | void | ) |
Configures all ZNP interface signals as inputs to allow the ZNP to be programmed. Toggles LED0 quickly to indicate application is running.
| void spiWrite | ( | unsigned char * | bytes, | |
| unsigned char | numBytes | |||
| ) |
Sends a message over SPI to the ZNP. Based on hal_board.c in CC2480 example application ZASA. The ZNP uses a "write-to-read" approach: to read data out, you must write data in. This is a private method that gets wrapped by other methods, e.g. spiSreq(), spiAreq, etc. To Write, set *bytes and numBytes. To Read, set *bytes only. Don't need to set numBytes because CC2530ZNP will stop when no more bytes are received.
| bytes | the data to be sent or received. | |
| numBytes | the number of bytes to be sent. This same buffer will be overwritten with the received data. |
Sends a message over SPI to the radio IC on USCI_B1. Based on hal_board.c in CC2480 example application ZASA. SPI uses a "write-to-read" approach to read data out, you must write data in. This is a private method that gets wrapped by other methods, e.g. spiSreq(), spiPoll(), etc. To Write, set *bytes, numBytes. To Read, set *bytes only. Don't need to set numBytes because CC2530ZNP will stop when no more bytes read.
| bytes | the data to be sent or received. | |
| numBytes | the number of bytes to be sent. This same buffer will be overwritten with the received data. |
Sends a message over SPI to the radio IC on USCI_B1. Based on hal_board.c in CC2480 example application ZASA. The ZNP uses a "write-to-read" approach to read data out, you must write data in. This is a private method that gets wrapped by other methods, e.g. spiSreq(), spiAreq, etc. To Write, set *bytes, numBytes. To Read, set *bytes only. Don't need to set numBytes because CC2530ZNP will stop when no more bytes read.
| bytes | the data to be sent or received. | |
| numBytes | the number of bytes to be sent. This same buffer will be overwritten with the received data. |
| void testLEDs | ( | ) |
Simple test of all LEDs
| void toggleLed | ( | unsigned char | whichLed | ) |
Toggles the specified LED.
| led | the LED to toggle, must be 0 or 1. |
Toggles the specified button LED.
| whichLed | the LED to toggle, must be 0-4. |
1.6.3